package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MobileSetmealMapper {
    /**
     * 查询所有套餐
     * @return
     */
    @Select("select * from t_setmeal")
    List<Setmeal> getSetmeal();

    /**
     * 根据id查询套餐
     * @param id
     * @return
     */
    @Select("select * from t_setmeal where id = #{id}")
    Setmeal findById(Integer id);

    /**
     * 根据套餐id查询检查组
     * @param id
     * @return
     */
    @Select("select * from t_checkgroup where id in (select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id})")
    List<CheckGroup> getCheckGroupsBySetmealId(Integer id);

    /**
     * 根据检查组id查询检查项
     */
    @Select("select * from t_checkitem where id in (select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id})")
    List<CheckItem> getCheckItemsByCheckGroupId(Integer id);
}
